﻿using System;

namespace CacheSharp.Core
{
    /// <summary>
    /// 写入接口
    /// </summary>
    internal interface IWriter
    {
        /// <summary>
        /// 当前的默认数据过期时间
        /// </summary>
        TimeSpan DefaultExpireTime { get; set; }

        /// <summary>
        /// 设置数据值
        /// </summary>
        /// <param name="groupName">群组名</param>
        /// <param name="key">键值</param>
        /// <param name="value">数据值</param>
        /// <param name="expiry">过期时间</param>
        /// <returns>设置是否成功</returns>
        /// <remarks>不存在键值时进行创建，存在时进行修改。</remarks>
        bool SetValue(string groupName, string key, object value, DateTime expiry);

        /// <summary>
        /// 设置数据值(采用默认的过期时间)
        /// </summary>
        /// <param name="groupName">群组名</param>
        /// <param name="key">键值</param>
        /// <param name="value">数据值</param>
        /// <returns>设置是否成功</returns>
        /// <remarks>不存在键值时进行创建，存在时进行修改。</remarks>
        bool SetValue(string groupName, string key, object value);

        /// <summary>
        /// 删除键值
        /// </summary>
        /// <param name="groupName">群组名</param>
        /// <param name="key">键值</param>
        /// <returns>操作是否成功</returns>
        bool Remove(string groupName, string key);

        /// <summary>
        /// 删除群组
        /// </summary>
        /// <param name="groupName">群组名</param>
        /// <returns>操作是否成功</returns>
        bool RemoveGroup(string groupName);

        /// <summary>
        /// 清空数据
        /// </summary>
        /// <returns>操作是否成功</returns>
        bool RemoveAll();
    }
}
